efform_onload = function ()
{	
	$("#ef_region_detail").hide();
}; 

efgrid_onRowClicked = function(grid_id, row_index) {
	if (grid_id == "ef_grid_r") {
		var grid = efgrid.getGridObject(grid_id);
		var fdForeignId = grid.getCellValueByColumnName(row_index, "fdKeyId");
		$('#fdForeignId').val(fdForeignId);
		var info = new EiInfo();
		info.set("fdForeignId", fdForeignId);
		EiCommunicator.send("ZMCH91", "query", info, ajax_callback);
	}
};
var ajax_callback = {
	onSuccess : function(eiInfo) {
		efwindow.hide();
		var grid = efgrid.getGridObject("ef_grid_d");
		grid.refresh(eiInfo);
		$('#ef_region_detail').show();
	},
	onFail : function(eMsg) {
		EFAlert("新增失败，原因：" + eMsg);
	}
};

/********************************************************************************
 ***********************************从表操作**************************************** 
 ********************************************************************************/
button_insert_onclick = function() {
	if (isSelected("ef_grid_d") == 0)
		return;
	efgrid.submitForm("ef_grid_d", "ZM", "ZMCH91", "insert", true);
};

button_update_onclick = function() {

	var grid = isSelected("ef_grid_d");
	if (grid == 0)
		return;

	efgrid.submitForm("ef_grid_d", "ZM", "ZMCH91", "update", true);
};

button_delete_onclick = function() {
	var grid = isSelected("ef_grid_d");
	if (grid == 0)
		return;
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if (r) {
			efgrid.submitForm("ef_grid_d", "ZM", "ZMCH91", "delete", true);
		}
	});
};  

efgrid_afterAddNewRow = function(grid_id) {
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_d") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdValidateDate", getNowDate());// 验收日期
			grid.getBlockData().setCell(rows[i], "fdValidateDepartmentId", $('#fdDepartmentId').val());// 验收单位
			grid.getBlockData().setCell(rows[i], "fdValidatePeople", $('#fdCreator').val());// 验收人
		}
	}
};
efgrid_onAjaxSubmitSuccess = function(gridId, service_name, method_name, eiInfo) {
	if (gridId == "ef_grid_d") {

		if (eiInfo.status != -1) {
			var grid = efgrid.getGridObject("ef_grid_d");
			grid.refresh(eiInfo);
		} else {
			submitCallBackEiMsg = eiInfo.msg;
		}
	} else {
		var grid = efgrid.getGridObject(gridId);
		grid.refresh(eiInfo);
	}
};
